import 'package:enterprise_v6_app/app/components/toast_widget.dart';
import 'package:enterprise_v6_app/app/core/http/http.dart';
import 'package:enterprise_v6_app/app/core/utils/interface.dart';
import 'package:enterprise_v6_app/app/core/values/images.dart';
import 'package:enterprise_v6_app/app/data/entities/double_control/promise_day_record_detail_entity.dart';
import 'package:enterprise_v6_app/app/data/entities/task/risk_base_page_entity.dart';
import 'package:enterprise_v6_app/router/app_pages.dart';
import 'package:get/get.dart';

///我的任务-风险管控
class RiskControlMeController extends GetxController {
  final productiveList = [
    RiskMeBasePage(
      title: '每日承诺审签',
      image: AppImages.icon_every_day_quiz,
      icon: AppImages.icon_base_right_arrow,
    ),
    RiskMeBasePage(
      title: '安全风险辨识管理审签',
      image: AppImages.icon_every_week_quiz,
      icon: AppImages.icon_base_right_arrow,
    ),
    RiskMeBasePage(
      title: '装置开停车大检修台账',
      image: AppImages.icon_every_week_quiz,
      icon: AppImages.icon_base_right_arrow,
    ),
    // RiskMeBasePage(
    //   title: '风险评估报告审签',
    //   image: AppImages.icon_every_month_quiz,
    //   icon: AppImages.icon_base_right_arrow,
    // ),
  ];

  void onClickItem(RiskMeBasePage e) async {
    switch (e.title) {
      case '每日承诺审签':
        //点击的时候 判断data是否有值 一天只承诺一次
        // getPromiseDayRecordListGetDetail();
        Get.toNamed(AppRoutes.dailyApprovePage, arguments: PromiseDayRecordDetailEntity());
        break;
      case '安全风险辨识管理审签':
        Get.toNamed(AppRoutes.riskControlApprovePage);
        break;
      case '装置开停车大检修台账':
        Get.toNamed(AppRoutes.equipmentStartShutdownPage);
        break;
      // case '风险评估报告审签':
      //   Get.toNamed(AppRoutes.riskAssessmentReportReviewApprovePage);
      //   break;
      default:
        break;
    }
  }

  ///查询详情  这里需要参数就可以查询
  void getPromiseDayRecordListGetDetail() async {
    final res = await HttpUtil()
        .generateGetRequest<PromiseDayRecordDetailEntity>(
          Interface.getTodayPromise,
        )
        .execute();
    res.onSuccess((result) {
      final PromiseDayRecordDetailEntity? data = result.data;
      if (data == null) {
        AppToast.showWarning('今天承诺已经完成~');
        return;
      }
      Get.toNamed(AppRoutes.dailyApprovePage, arguments: data);
      // Get.toNamed(AppRoutes.dailyCommitmentDetailApprovePage, arguments: data);
    });
    update();
  }
}
